<div id="divAllClients">
<table border='0' style='width: 90%'>
    <tr>
        <th>ID</th>
        <th>Client Name</th>
        <th>Owner/Manager</th>
        <th>Address</th>
       
        <th>Date Added</th>
        <th>Task</th>
    </td>
<?php
foreach($clients as $client)
{
  echo'<tr>';
    echo'<td>'.$client['id'].'</td>';
    echo'<td>'.$client['name'].'</td>';
    echo'<td>'.$client['owner'].'</td>';
    echo'<td>'.$client['address'].'</td>';
   
    echo'<td>'.$this->date->format($client['date_added'],'STANDARD_DATE').'</td>';
    echo'<td>'.'<span class="link clientEdit" data-id="'.$client['id'].'">edit</span> | <span class="link clientDelete" data-id="'.$client['id'].'">delete</span>'.'</td>';
  echo'</tr>';  
}
?>
</table>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $('.clientEdit').click(function(){
        var id = $(this).attr('data-id');
       
       $.ajax({
           statusCode : { 404: function(){alert('Not Found');} },
           type       : 'POST',
           data       : {id : id},
           url        : '../ajax/ir_edit_client',
           success    : function(res){
                            $('#divClientInfo').html(null);
                            $('#divClientInfo').html(res);
                        }
       });
       
    });
    
    $('.clientDelete').click(function(){
        var id = $(this).attr('data-id');
       
       if(confirm('Delete this client?'))
         {
            $.ajax({
                statusCode : { 404: function(){alert('Not Found');} },
                type       : 'POST',
                data       : {id : id},
                url        : '../ajax/ir_delete_client',
                success    : function(res){
                                $('#divAllClients').html(null);
                                $('#divAllClients').html(res);
                             }
            });
         }
    });
    
    
});
</script>